package com.ww.demo;

import java.math.BigDecimal;

public class CastDemo {

	public <T> void cast(T data) {
		Person target = null;
		if (data instanceof Person) {
			target = (Person) data;			
			System.out.println("data:" + data);			
		}
		

		target.setIncome(new BigDecimal("50000"));
		target.setAge(30);
		
		System.out.println("target:" + target);
		
		System.out.println("data:" + data);
	}
	
	public static void main(String[] args) {
		CastDemo demo = new CastDemo();
		Person person = new Person();
		person.setAge(20);
		person.setName("abc");
		person.setIncome(new BigDecimal("2000"));
		demo.cast(person);
	}
}


class Person {
	
	private Integer age;
	
	private String name;
	
	private BigDecimal income;

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public BigDecimal getIncome() {
		return income;
	}

	public void setIncome(BigDecimal income) {
		this.income = income;
	}

	@Override
	public String toString() {
		return "Person [age=" + age + ", name=" + name + ", income=" + income + "]";
	}
	
	
}